/*
The MIT License
Copyright (c) 2019 Lehrstuhl Informatik 11 - RWTH Aachen University
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE

This file is part of embeddedRTPS.

Author: i11 - Embedded Software, RWTH Aachen University
*/

#ifndef RTPS_MESSAGEFACTORY_H
#define RTPS_MESSAGEFACTORY_H

#include "rtps/common/types.h"
#include "rtps/config.h"
#include "rtps/messages/MessageTypes.h"
#include "rtps/utils/sysFunctions.h"

//#include <array>
//#include <cstdint>
extern const char PROTOCOL_TYPE[4];
extern const uint8_t numBytesUntilEndOfLength;

void rtps_MessageFactory_addHeader(struct rtps_PBufWrapper *buffer, const struct GuidPrefix_t *guidPrefix);
//bool addSubMessageInfoDST(Buffer &buffer, GuidPrefix_t &dst);
void rtps_MessageFactory_addSubMessageTimeStamp(struct rtps_PBufWrapper *buffer, bool setInvalid);
void rtps_MessageFactory_addSubMessageData(struct rtps_PBufWrapper *buffer, struct rtps_PBufWrapper *filledPayload,
                       bool containsInlineQos, const struct SequenceNumber_t *SN,
                       const struct EntityId_t *writerID, const struct EntityId_t *readerID);

void rtps_MessageFactory_addHeartbeat(struct rtps_PBufWrapper *buffer, 
struct EntityId_t *writerId, struct EntityId_t *readerId,
                  struct SequenceNumber_t *firstSN, struct SequenceNumber_t *lastSN,
                  Count_t count);            
void rtps_MessageFactory_addAckNack(struct rtps_PBufWrapper *buffer, struct EntityId_t *writerId, struct EntityId_t *readerId, struct SequenceNumberSet *readerSNState, Count_t count, bool final_flag);                

#endif // RTPS_MESSAGEFACTORY_H

